/**
 */
package de.thwildau.tm.moses.xabnf.xabnf.impl;

import de.thwildau.tm.moses.xabnf.xabnf.Bindings;
import de.thwildau.tm.moses.xabnf.xabnf.GeneratorModel;
import de.thwildau.tm.moses.xabnf.xabnf.Xabnf;
import de.thwildau.tm.moses.xabnf.xabnf.XabnfPackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Xabnf</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.thwildau.tm.moses.xabnf.xabnf.impl.XabnfImpl#getGeneratorModel <em>Generator Model</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.xabnf.xabnf.impl.XabnfImpl#getBindings <em>Bindings</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class XabnfImpl extends MinimalEObjectImpl.Container implements Xabnf
{
  /**
   * The cached value of the '{@link #getGeneratorModel() <em>Generator Model</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getGeneratorModel()
   * @generated
   * @ordered
   */
  protected GeneratorModel generatorModel;

  /**
   * The cached value of the '{@link #getBindings() <em>Bindings</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getBindings()
   * @generated
   * @ordered
   */
  protected Bindings bindings;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected XabnfImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return XabnfPackage.Literals.XABNF;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public GeneratorModel getGeneratorModel()
  {
    return generatorModel;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetGeneratorModel(GeneratorModel newGeneratorModel, NotificationChain msgs)
  {
    GeneratorModel oldGeneratorModel = generatorModel;
    generatorModel = newGeneratorModel;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XabnfPackage.XABNF__GENERATOR_MODEL, oldGeneratorModel, newGeneratorModel);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setGeneratorModel(GeneratorModel newGeneratorModel)
  {
    if (newGeneratorModel != generatorModel)
    {
      NotificationChain msgs = null;
      if (generatorModel != null)
        msgs = ((InternalEObject)generatorModel).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - XabnfPackage.XABNF__GENERATOR_MODEL, null, msgs);
      if (newGeneratorModel != null)
        msgs = ((InternalEObject)newGeneratorModel).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - XabnfPackage.XABNF__GENERATOR_MODEL, null, msgs);
      msgs = basicSetGeneratorModel(newGeneratorModel, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, XabnfPackage.XABNF__GENERATOR_MODEL, newGeneratorModel, newGeneratorModel));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Bindings getBindings()
  {
    return bindings;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetBindings(Bindings newBindings, NotificationChain msgs)
  {
    Bindings oldBindings = bindings;
    bindings = newBindings;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XabnfPackage.XABNF__BINDINGS, oldBindings, newBindings);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setBindings(Bindings newBindings)
  {
    if (newBindings != bindings)
    {
      NotificationChain msgs = null;
      if (bindings != null)
        msgs = ((InternalEObject)bindings).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - XabnfPackage.XABNF__BINDINGS, null, msgs);
      if (newBindings != null)
        msgs = ((InternalEObject)newBindings).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - XabnfPackage.XABNF__BINDINGS, null, msgs);
      msgs = basicSetBindings(newBindings, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, XabnfPackage.XABNF__BINDINGS, newBindings, newBindings));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case XabnfPackage.XABNF__GENERATOR_MODEL:
        return basicSetGeneratorModel(null, msgs);
      case XabnfPackage.XABNF__BINDINGS:
        return basicSetBindings(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case XabnfPackage.XABNF__GENERATOR_MODEL:
        return getGeneratorModel();
      case XabnfPackage.XABNF__BINDINGS:
        return getBindings();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case XabnfPackage.XABNF__GENERATOR_MODEL:
        setGeneratorModel((GeneratorModel)newValue);
        return;
      case XabnfPackage.XABNF__BINDINGS:
        setBindings((Bindings)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case XabnfPackage.XABNF__GENERATOR_MODEL:
        setGeneratorModel((GeneratorModel)null);
        return;
      case XabnfPackage.XABNF__BINDINGS:
        setBindings((Bindings)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case XabnfPackage.XABNF__GENERATOR_MODEL:
        return generatorModel != null;
      case XabnfPackage.XABNF__BINDINGS:
        return bindings != null;
    }
    return super.eIsSet(featureID);
  }

} //XabnfImpl
